The Ecology Section at the USGS Conte Laboratory has studied brook trout in West Brook, a small 3rd order stream in Whately MA, since 1997.
They observed body size variation in Young-of-the-Year (YOY) brook trout (Salvelinus fontinalis) in the fall. ( Photo above ). Why is this variation in body size occurring, is is a random or is there a reproductive strategy behind it.
Knowing the mechanisms behind the body size variation are important because being bigger than the YOY brook trout in a cohort increase that individual probability of overwinter survival and age at first reproduction.
What is causing the observed body size variation in YOY brook trout? Is it a difference in emergence timing, a difference in growth rate, or a combination of the two variables.
5.1 Questions
Although there are a lot of variables such as, food availability, habitat, flow and temperature all influencing body size. We want to look at how Emergence Date (Birth date) and Growth Rate influence the broad size distribution of YOY brook trout observed in the fall.
What effect does growth rate have on brook trout YOY body size?
What effect does emergence date ( birth ) have on brook trout YOY body size?
6 Conceptual Model
This section provides a conceptual model that visualizes how growth rate and emergence date affect the body size distribution for the first electrofishing sample. There are two conceptual models, one that looks at the data visually and the second looks at the effect of a dependent variable ( emergence date or growth rate) on a response variable (body size).
First, with Simulated Data (Visual) we display body size on the y-axis and time on the x-axis.
Second, with Simulated Data (Model) examine how growth rate and emergence date, as dependent variables, influence the body size, the response variable.
6.1 Models
Same Emergence Date - Different Growth Rate ( SE/DG), model assumes the growth rate varies among individuals but they emerge at the same time. The largest YOY grew the fastest and the smallest YOY grew the slowest.
Different Emergence Date - Same Growth Rate (DE/SG), assumes the growth rate remains the same but the emergence time varies among individuals. The earliest emerges become the largest YOY and the later emerges become the smallest YOY.
Different Emergence Date and Growth Rate (Mix), assumes that both growth rate and emergence date vary among individuals with each one contributing the the size variation observed in the fall. Hypothetically a YOY can emerge later, but into a more favorable environment thus grow faster and become one of the larger YOY in the fall.
6.2 Simulated Data ( Visual )
First, we display body size on the y-axis and time on the x-axis. Based off field observations 20mm is assumed to be the body size brook trout YOY emerge at. This allows use to visually look what real data would look like for each model.
A concptural model of Same Emergence Date - Different Growth Rate on spring growth period for YOY brook trout. Fork Length (mm) on the y axis and Emergence Date (Day of Year) on the x axis.
A concptural model of Different Emergence Date - Same Growth Rate on spring growth period for YOY brook trout. Fork Length (mm) on the y axis and Emergence Date (Day of Year) on the x axis.
A concptural model of Different Emergence Date and Growth Rate on spring growth period for YOY brook trout. Fork Length (mm) on the y axis and Emergence Date (Day of Year) on the x axis.
The effect of Growth Rate (Independent Variable) x-axis or Fork Length (mm) (Dependent Variable) y-axis , colored by model. Model are, DE/SG (Different Emergence - Same Growth Rate), Mix = (Different Emergence Date and Growth Rate), and SE/DG (Same Emergence Date and Different Growth Rate)
The effect of Emergence Date (Independent Variable) x-axis or Fork Length (mm) (Dependent Variable) y-axis , colored by model. Model are, DE/SG (Different Emergence - Same Growth Rate), Mix = (Different Emergence Date and Growth Rate), and SE/DG (Same Emergence Date and Different Growth Rate)
The effect of Emergence Date (Independent Variable) x-axis or Fork Length (mm) (Dependent Variable) y-axis , colored by model. The data is from Avery Brook Summer electrofishing sample July 21st 2022
The effect of Emergence Date (Independent Variable) x-axis or Fork Length (mm) (Dependent Variable) y-axis , colored by model. The data is from Avery Brook Summer electrofishing sample July 21st 2022
Call:
lm(formula = forkLength_DateKilled ~ slope, data = new)
Residuals:
Min 1Q Median 3Q Max
-1.89739 -1.11063 -0.00066 1.13793 2.29610
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 17.082 3.664 4.663 0.00231 **
slope 89.480 8.218 10.888 1.22e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.582 on 7 degrees of freedom
Multiple R-squared: 0.9442, Adjusted R-squared: 0.9363
F-statistic: 118.5 on 1 and 7 DF, p-value: 1.218e-05
The effect of Emergence Date (Independent Variable) x-axis or Fork Length (mm) (Dependent Variable) y-axis , colored by model. The data is from Avery Brook Summer electrofishing sample July 21st 2022
The effect of Emergence Date (Independent Variable) x-axis or Fork Length (mm) (Dependent Variable) y-axis , colored by model. The data is from Obear Brook Summer electrofishing sample July 15th 2015
7.3 Results / Conclusions
Fork Length (mm) vs Emergence Date
Avery Brook Summer 2022 - R Squared 0.34
Obear Brook Summer 2015 - R Squared 0.27
Fork Length (mm) against Growth Rate (mm/d)
Avery Brook Summer 2022 - R Squared 0.93
Obear Brook Summer 2015 - R Squared 1.00
Growth Rate had a stronger relationship than emergence date but the data is highly correlated so we need a different way to estimate growth rate to account for the daily variation.
8 Back calculation of fish size from otolith size
8.1 Steps
Determine the relationship between brook trout fork length and otolith size.
Access the daily body size estimates from ring spacing measurements.
Apply methodology to one stream from one year.
8.2 Otolith Radius vs Body Size
There is a positive relationship between otolith radius and fork length.
R Squared = 0.92
We conducted a mixed effects model analysis to determine whether the sampled stream and year could explain the variance. Unfortunately, the random effects only contributed a minimal amount to the overall variance.
8.3 Ring Spacing Methodology
A sagittal otolith is divided into four quadrants.
Posterior-Ventral
Posterior-Dorsal
Anterior-Ventral
Anterior-Dorsal
All Counting was done in the Posterior-Dorsal Quadrant.
Ring spacing is measured along a 45 degree angle in the Posterior-Dorsal Quadrant
Starting at the Posterior most primordia of the primordium.
Ending at the edge of the Otolith.
This ensures consistent measurements among samples.
Posterior-Dorsal Quadrant with Counting Line
The distance between every consecutive ring was measured starting at the edge and ending at the posterior primordium.
The distances between the consecutive rings were used to calculate the otolith radius when the ring was formed.
The otolith radius is then run through a linear equation to calculate the Fishes Fork Length for a given rings size.
Zoomed in Posterior-Dorsal Quadrant.
8.4 Error Checking
8.4.1 Ring Measuring Error
Check for reader bias.
Measure ring spacing and calculate estimated body size for Ten otolith blindly.
Compare the size estimates and calculate the percent error in them.
---title: "Yong-of-the-year (YOY) Brook Trout (*Salvelinus fontinalis*) Body Size Model"format: html: self-contained: true toc: trueeditor: visual---```{r}#| echo: false#| message: false#| warning: false#| include: false# =============# Load Packages# =============library(ggpmisc)library(ggpubr)library(ggthemes)library(grid)library(here)library(lme4)library(lubridate)library(maditr)library(mgcv)library(scales)library(tidyverse)library(weathermetrics)source(here::here( "DataAnalysis" , "Code" , "Functions", "themePublication.R" ))source(here::here( "DataAnalysis" , "Code" , "Functions", "otolithDateCalculations.R" ))# =========# Load Data# =========setwd(here::here( "DataAnalysis" , "DataOut" , "Biological","predictedLifeEvents" ))growthRateOtolith <-readRDS( "growthRateOtolith.rds" )SizeDisModel <-readRDS( "SizeDisModel.rds" ) lifeEventsMaster <-readRDS( "lifeEventsMaster.rds" )streamFishOtolithKey <-readRDS( "streamFishOtolithKey.rds")# ============# Process Data# ============# ---------# Mean Size # ---------emergenceGrowth <- growthRateOtolith %>%group_by(slideNumber) %>%filter( lengthAtAgeBI <=20 ) %>%summarise( emergenceDate =max(date) )emergenceDate <- growthRateOtolith %>%filter( lengthAtAgeBI >19 ) %>%select( slideNumber, methodOfCapture, changeInSize ) %>%na.omit() %>%group_by( slideNumber , methodOfCapture ) %>%summarise(meanGrowth =mean(changeInSize)) %>%left_join(lifeEventsMaster, by =c('slideNumber'='slideNumber')) %>%left_join( emergenceGrowth, by =c('slideNumber'='slideNumber') ) %>%mutate( emergenceSizeDOY =yday(detectionDate),emergenceTempDOY =yday(emergenceDate),birthYear =year(detectionDate))# -----------------------# ReFormat Data For Model# -----------------------finalFork <- streamFishOtolithKey %>%select( slideNumber , forkLength) %>%rename( forkLengthFinal = forkLength ) %>%mutate( slideNumber =as.factor(slideNumber) )emergenceDateModel <- emergenceDate %>%filter( lifeEvent =="Emergence" , river %in%c("Avery Brook" , "West Whately Brook","Obear Brook" )) %>%mutate( slideNumber =as.factor(slideNumber),year =year(detectionDate)) %>%left_join( finalFork, by =c( 'slideNumber'='slideNumber'))```# Background- The Ecology Section at the USGS Conte Laboratory has studied brook trout in West Brook, a small 3rd order stream in Whately MA, since 1997.- They observed body size variation in Young-of-the-Year (YOY) brook trout (*Salvelinus fontinalis*) in the fall. ( Photo above ). Why is this variation in body size occurring, is is a random or is there a reproductive strategy behind it.- Knowing the mechanisms behind the body size variation are important because being bigger than the YOY brook trout in a cohort increase that individual probability of overwinter survival and age at first reproduction.- What is causing the observed body size variation in YOY brook trout? Is it a difference in emergence timing, a difference in growth rate, or a combination of the two variables.## QuestionsAlthough there are a lot of variables such as, food availability, habitat, flow and temperature all influencing body size. We want to look at how Emergence Date (Birth date) and Growth Rate influence the broad size distribution of YOY brook trout observed in the fall.1. What effect does growth rate have on brook trout YOY body size?2. What effect does emergence date ( birth ) have on brook trout YOY body size?# Conceptual ModelThis section provides a conceptual model that visualizes how growth rate and emergence date affect the body size distribution for the first electrofishing sample. There are two conceptual models, one that looks at the data visually and the second looks at the effect of a dependent variable ( emergence date or growth rate) on a response variable (body size).1. First, with **Simulated Data (Visual)** we display body size on the y-axis and time on the x-axis.2. Second, with **Simulated Data (Model)** examine how growth rate and emergence date, as dependent variables, influence the body size, the response variable.## Models- **Same Emergence Date - Different Growth Rate ( SE/DG),** model assumes the growth rate varies among individuals but they emerge at the same time. The largest YOY grew the fastest and the smallest YOY grew the slowest.- **Different Emergence Date - Same Growth Rate (DE/SG),** assumes the growth rate remains the same but the emergence time varies among individuals. The earliest emerges become the largest YOY and the later emerges become the smallest YOY.- **Different Emergence Date and Growth Rate (Mix)**, assumes that both growth rate and emergence date vary among individuals with each one contributing the the size variation observed in the fall. Hypothetically a YOY can emerge later, but into a more favorable environment thus grow faster and become one of the larger YOY in the fall.## Simulated Data ( Visual )- First, we display body size on the y-axis and time on the x-axis. Based off field observations 20mm is assumed to be the body size brook trout YOY emerge at. This allows use to visually look what real data would look like for each model.::: panel-tabset### Same Emergence Date - Different Growth Rate```{r}#| echo: false#| message: false#| warning: false#| fig-cap: "A concptural model of Same Emergence Date - Different Growth Rate on spring growth period for YOY brook trout. Fork Length (mm) on the y axis and Emergence Date (Day of Year) on the x axis."conceptualModel <-function(mOdel, xDat, xLab){SizeDisModel %>%filter( model == mOdel ) %>%ggplot(aes_string( y ="forkLength" , x = xDat, group ="slideNumber")) +geom_point() +geom_line() +labs( x = xLab , y ="Fork Length (mm)") +theme_Publication() }conceptualModel( "Same Emergence/Diff Growth","dayofYear" ,"Emergence Date (Day of Year)" )```### Different Emergence Date - Same Growth Rate```{r}#| echo: false#| message: false#| warning: false#| fig-cap: "A concptural model of Different Emergence Date - Same Growth Rate on spring growth period for YOY brook trout. Fork Length (mm) on the y axis and Emergence Date (Day of Year) on the x axis."conceptualModel("Different Emergence/Same Growth","dayofYear" ,"Emergence Date (Day of Year)" )```### Different Emergence Date and Growth Rate```{r}#| echo: false#| message: false#| warning: false#| fig-cap: "A concptural model of Different Emergence Date and Growth Rate on spring growth period for YOY brook trout. Fork Length (mm) on the y axis and Emergence Date (Day of Year) on the x axis."conceptualModel("Mix","dayofYear" ,"Emergence Date (Day of Year)" )```:::## Simulated Data ( Model )::: panel-tabset### Growth Rate Vs Body Size```{r}#| echo: false#| message: false#| warning: false#| label: Effect of Growth Rate on Fork Length#| fig-cap: "The effect of Growth Rate (Independent Variable) x-axis or Fork Length (mm) (Dependent Variable) y-axis , colored by model. Model are, DE/SG (Different Emergence - Same Growth Rate), Mix = (Different Emergence Date and Growth Rate), and SE/DG (Same Emergence Date and Different Growth Rate) "cc <- SizeDisModel %>%pivot_wider( names_from = event, values_from =c(forkLength, dayofYear)) %>%mutate( y1y2 = forkLength_dateKilled-forkLength_emergence,x1x2 = dayofYear_dateKilled-dayofYear_emergence, slope = y1y2/x1x2, model =ifelse( model =="Different Emergence/Same Growth" , "DE/SG" ,ifelse( model =="Same Emergence/Diff Growth" , "SE/DG" , "Mix")))cc %>%ggplot(aes( y = forkLength_dateKilled, x = slope,colour = model)) +geom_point() +labs( x ="Mean Growth Rate (mm/d)" , y ="Fork Length (mm)",colour ="Model") +theme_Publication() +geom_smooth( method = lm, se =FALSE )+scale_colour_Publication()# facet_wrap(.~model , labeller = label_wrap_gen(10)) ```### Emergence Date Vs Body Size```{r}#| echo: false#| message: false#| warning: false#| label: Effect of Emergence Date on Fork Length#| fig-cap: "The effect of Emergence Date (Independent Variable) x-axis or Fork Length (mm) (Dependent Variable) y-axis , colored by model. Model are, DE/SG (Different Emergence - Same Growth Rate), Mix = (Different Emergence Date and Growth Rate), and SE/DG (Same Emergence Date and Different Growth Rate) "cc %>%ggplot(aes( y = forkLength_dateKilled, x = dayofYear_emergence,colour = model), ) +geom_point() +labs( x ="Emergence Date (Day of Year)" , y ="Fork Length (mm)",colour ="Model") +theme_Publication() +geom_smooth( method = lm, se =FALSE )+scale_colour_Publication()```:::# Stream Data## Avery Brook::: panel-tabset### Size Distribution vs Emergence Date (2022-07-21)```{r}#| echo: false#| message: false#| warning: false lifeEventsMaster %>%filter( river =="Avery Brook", dateKilled =="2022-07-21", lifeEvent %in%c( "DateKilled" , "Emergence")) %>%ggplot( aes( y = forkLength , x = dayOfYear,colour =as.factor(slideNumber)))+geom_point() +geom_line()+ggtitle("Avery Brook 2022/07/13") +labs( y ="Fork Length (mm)", x ="Emergence Date (Day of Year)" ,colour ="Fish Number" ) +theme_Publication()```### Fork Length vs Emergence Date (2022-07-21)```{r}#| echo: false#| message: false#| warning: false#| fig-cap: "The effect of Emergence Date (Independent Variable) x-axis or Fork Length (mm) (Dependent Variable) y-axis , colored by model. The data is from Avery Brook Summer electrofishing sample July 21st 2022 "forkLength <- lifeEventsMaster %>%filter( river =="Avery Brook", dateKilled =="2022-07-21", lifeEvent %in%c( "DateKilled" )) %>%select( slideNumber, forkLength )emergenceDate <- lifeEventsMaster %>%filter( river =="Avery Brook", dateKilled =="2022-07-21", lifeEvent %in%c( "Emergence" )) %>%select( slideNumber, detectionDate ) data <- forkLength %>%left_join( emergenceDate , by =c( "slideNumber"="slideNumber"))data %>%ggplot( aes( y = forkLength , x =yday(detectionDate ))) +geom_point() +labs( y ="Fork Length (mm)", x ="Day Of Year")+geom_smooth(method = lm , se = F) +stat_cor(label.y =67, label.x =123) +theme_Publication() +scale_colour_Publication()```### Fork Length (mm) vs Growth Rate (mm/d)```{r}#| echo: false#| message: false#| warning: false#| fig-cap: "The effect of Emergence Date (Independent Variable) x-axis or Fork Length (mm) (Dependent Variable) y-axis , colored by model. The data is from Avery Brook Summer electrofishing sample July 21st 2022 "forkLength <- lifeEventsMaster %>%filter( river =="Avery Brook", dateKilled =="2022-07-21", lifeEvent %in%c( "DateKilled","Emergence")) %>%mutate(dayOfYear =yday(detectionDate)) %>%select( lifeEvent, slideNumber, dayOfYear, forkLength ) new <- forkLength %>%pivot_wider( names_from = lifeEvent , values_from =c(forkLength, dayOfYear)) %>%na.omit() %>%mutate( y1y2 = forkLength_DateKilled-forkLength_Emergence,x1x2 =dayOfYear_DateKilled-dayOfYear_Emergence,slope = y1y2/x1x2)new %>%ggplot(aes( y = forkLength_DateKilled , x = slope )) +geom_point() +labs( y ="Fork Lenght (mm)" ,x ="Growth Rate (mm/d)") +stat_poly_line() +stat_cor(label.y =70)+theme_Publication()summary(lm(forkLength_DateKilled ~ slope, data = new))```:::## Obear Brook Upper::: panel-tabset### Size Distribution vs Emergence Date (2022-07-21)```{r}#| echo: false#| message: false#| warning: false lifeEventsMaster %>%filter( river =="Obear Brook", dateKilled =="2015-07-13", lifeEvent %in%c( "DateKilled" , "Emergence")) %>%ggplot( aes( y = forkLength , x = dayOfYear,colour =as.factor(slideNumber)))+geom_point() +geom_line()+ggtitle("Avery Brook 2022/07/13") +labs( y ="Fork Length (mm)", x ="Emergence Date (Day of Year)" ,colour ="Fish Number" ) +theme_Publication()```### Fork Length vs Emergence Date (2022-07-21)```{r}#| echo: false#| message: false#| warning: false#| fig-cap: "The effect of Emergence Date (Independent Variable) x-axis or Fork Length (mm) (Dependent Variable) y-axis , colored by model. The data is from Avery Brook Summer electrofishing sample July 21st 2022 "forkLength <- lifeEventsMaster %>%filter( river =="Obear Brook", dateKilled =="2015-07-13", lifeEvent %in%c( "DateKilled" )) %>%select( slideNumber, forkLength )emergenceDate <- lifeEventsMaster %>%filter( river =="Obear Brook", dateKilled =="2015-07-13", lifeEvent %in%c( "Emergence" )) %>%select( slideNumber, detectionDate ) data <- forkLength %>%left_join( emergenceDate , by =c( "slideNumber"="slideNumber"))data %>%ggplot( aes( y = forkLength , x =yday(detectionDate ))) +geom_point() +labs( y ="Fork Length (mm)", x ="Day Of Year") +geom_smooth(method = lm , se = F) +stat_cor(label.y =60, label.x =119.5) +theme_Publication()```### Fork Length (mm) vs Growth Rate (mm/d)```{r}#| echo: false#| message: false#| warning: false#| fig-cap: "The effect of Emergence Date (Independent Variable) x-axis or Fork Length (mm) (Dependent Variable) y-axis , colored by model. The data is from Obear Brook Summer electrofishing sample July 15th 2015 "forkLength <- lifeEventsMaster %>%filter( river =="Obear Brook", dateKilled =="2015-07-13", lifeEvent %in%c( "DateKilled","Emergence")) %>%mutate(dayOfYear =yday(detectionDate)) %>%select( lifeEvent, slideNumber, dayOfYear, forkLength ) new <- forkLength %>%pivot_wider( names_from = lifeEvent , values_from =c(forkLength, dayOfYear)) %>%na.omit() %>%mutate( y1y2 = forkLength_DateKilled-forkLength_Emergence,x1x2 =dayOfYear_DateKilled-dayOfYear_Emergence,slope = y1y2/x1x2)new %>%ggplot(aes( y = forkLength_DateKilled , x = slope )) +geom_point() +labs( y ="Fork Lenght (mm)" ,x ="Growth Rate (mm/d)") +stat_poly_line() +stat_cor(label.y =60)+theme_Publication()```:::## Results / Conclusions- Fork Length (mm) vs Emergence Date - Avery Brook Summer 2022 - R Squared **0.34** - Obear Brook Summer 2015 - R Squared **0.27**- Fork Length (mm) against Growth Rate (mm/d) - Avery Brook Summer 2022 - R Squared **0.93** - Obear Brook Summer 2015 - R Squared **1.00**- Growth Rate had a stronger relationship than emergence date but the data is highly correlated so we need a different way to estimate growth rate to account for the daily variation.# Back calculation of fish size from otolith size## Steps1. **Determine the relationship between brook trout fork length and otolith size.**2. **Access the daily body size estimates from ring spacing measurements.**3. **Apply methodology to one stream from one year.**## Otolith Radius vs Body Size```{r}#| echo: false#| message: false#| warning: falsestreamFishOtolithKey %>%ggplot(aes( y = forkLength , x = radius)) +geom_point() +labs( y ="Fork Length (mm)" ,x ="Otolith Radius (um)") +ylim( 0, 100) +xlim( 0, 800) +scale_colour_Publication() +theme_Publication() +geom_smooth(method ="lm", fullrange=TRUE)```1. **There is a positive relationship between otolith radius and fork length.** 1. **R Squared = 0.92**2. **We conducted a mixed effects model analysis to determine whether the sampled stream and year could explain the variance. Unfortunately, the random effects only contributed a minimal amount to the overall variance.**## Ring Spacing Methodology1. A sagittal otolith is divided into four quadrants. 1. Posterior-Ventral 2. Posterior-Dorsal 3. Anterior-Ventral 4. Anterior-Dorsal2. All Counting was done in the Posterior-Dorsal Quadrant.3. Ring spacing is measured along a 45 degree angle in the Posterior-Dorsal Quadrant - Starting at the Posterior most primordia of the primordium. - Ending at the edge of the Otolith.4. This ensures consistent measurements among samples.5. The distance between every consecutive ring was measured starting at the edge and ending at the posterior primordium.6. The distances between the consecutive rings were used to calculate the otolith radius when the ring was formed.7. The otolith radius is then run through a linear equation to calculate the Fishes Fork Length for a given rings size.## Error Checking### Ring Measuring Error1. Check for reader bias.2. Measure ring spacing and calculate estimated body size for Ten otolith blindly.3. Compare the size estimates and calculate the percent error in them.4. Percent Error should be below 10%.5. Two out of Ten percent error over 10%.::: panel-tabset#### Graph```{r}#| echo: false#| message: false#| warning: falseuni <- growthRateOtolith %>%filter( slideNumber %in%c("3748" , "6329"), counts ==2, lengthAtAgeFL >19 )uni <-unique(uni$slideNumber)secondCount <- growthRateOtolith %>%filter( slideNumber %in% uni, lengthAtAgeFL >19) %>%mutate(dOY =yday(date))secondCount %>%ggplot(aes( y = lengthAtAgeFL , x = dOY,colour =as.factor(counts))) +geom_line() +labs( y ="Fork Length (mm)" , x ="Day of Year", colour ="Count Number") +facet_wrap(.~slideNumber) +theme_Publication() +scale_colour_Publication() +theme(axis.text.x =element_text(angle =45, hjust =1))```#### Percent Error```{r}# -------------------------------------------------# Extract All fish that were ring space aged twice. # -------------------------------------------------uni <- growthRateOtolith %>%filter( counts ==2, lengthAtAgeFL >0 )uni <-unique(uni$slideNumber)secondCount <- growthRateOtolith %>%filter(slideNumber %in% uni) %>%mutate(dOY =yday(date))# --------------------------------------# Data Frame Fish ring spaced aged twice# --------------------------------------secondCounts <- uni %>%as.data.frame()colnames(secondCounts)[1] ="slideNumber"# --------------------------# Nest Data for map function# --------------------------nestedData <- secondCounts %>%group_by(slideNumber) %>%nest() percentErrorBackCalculate <- nestedData %>%mutate( percentError =map( slideNumber, otolithPercentError ) ) %>%unnest()# ---------------------------------# Plot Percent Error with Histagram# --------------------------------percentErrorBackCalculate %>%ggplot(aes( x = percentError )) +geom_histogram(aes( y = ..density..),colour =1, fill ="white") +geom_density( lwd =1, colour =4,fill =4, alpha =0.25) +labs( y ="Density" , x ="Percent Error") +theme_Publication()```:::# Results## Raw Data ### Avery Brook #### Change in size accross Time (2022)```{r}#| echo: false#| message: false#| warning: falseaveryGrowth <- growthRateOtolith %>%filter( river =="Avery Brook" , lengthAtAgeBI >20) %>%mutate( dayOfYear =yday(date), year =year(date))averyGrowth %>%filter( ) %>%ggplot( aes( y = lengthAtAgeBI, x = dayOfYear, group = slideNumber,colour =as.factor(methodOfCapture))) +geom_line() +# geom_smooth(method = "gam") +labs( y ="Fork Length (mm)",x ="Day Of Year" , colour ="Method Of Capture" ) +scale_colour_Publication() +theme_Publication() ```#### Daily Growth Rate::: panel-tabset##### Dip Net```{r}#| echo: false#| message: false#| warning: falseaveryGrowth %>%filter( methodOfCapture =="Dip Net") %>%ggplot(aes( y = changeInSize, x = dayOfYear, colour =as.factor(forkLength))) +geom_point() +# geom_line() +labs( y ="Growth Rate (mm/d)" , x ="Date" ,colour ="Fork Length (mm)") +geom_smooth(method ="lm", se =FALSE) +scale_colour_Publication() +theme_Publication() ```##### Electrofisher```{r}#| echo: false#| message: false#| warning: falseaveryGrowth %>%filter( methodOfCapture =="Electrofisher") %>%ggplot(aes( y = changeInSize, x = dayOfYear, colour =as.factor(forkLength))) +geom_point() +# geom_line() +labs( y ="Growth Rate (mm/d)" , x ="Day Of Year" ,colour ="Fork Length (mm)") +geom_smooth(method ="lm", se = F) +theme_Publication() +scale_colour_Publication() ```:::## Analyzed Data### Fork Length (mm) vs Growth Rate (mm/d)```{r}#| echo: false#| message: false#| warning: falseaveryGrowth <- growthRateOtolith %>%filter( river =="Obear Brook" , lengthAtAgeBI >20) %>%mutate( dayOfYear =yday(date), year =year(date))cc <- growthRateOtolith %>%filter( river %in%c( "Avery Brook" , "Obear Brook" , "Sanderson Brook","West Whately Brook", "Roaring Brook")) %>%mutate( year =year(dateKilled) ) %>%group_by( river, slideNumber, forkLength, year) %>%summarise( mean =mean(changeInSize) )cc %>%ggplot(aes( y = mean,x = forkLength)) +geom_point() +xlim( 18 , 80) +ylim(0.1 , 0.5) +stat_poly_line() +stat_cor(label.y =0.45)+labs( y ="Growth Rate (mm/day)" , x ="Fork Length (mm) at Capture" ) +theme_Publication() +scale_colour_Publication() ``````{r}#| echo: false#| message: false#| warning: falseforkandAge <- growthRateOtolith %>%filter( counts ==1 , lengthAtAgeBI >19, river %in%c( "West Whately" , "Pond Brook" , "Roaring Brook","Sanderson Brook","Obear Brook","Four Mile Brook")) %>%group_by( slideNumber, river ) %>%summarise( daysPostEmergence =n(),forkLength =max(forkLength) )gam_model =gam(forkLength~s(daysPostEmergence), data = forkandAge)#summary(gam_model)forkandAge %>%ggplot( aes( y = forkLength, x = daysPostEmergence ))+geom_point() +geom_line(aes(y =fitted(gam_model)), colour ="blue", size =1.2)+labs( x ="Days Post Emergence" , y ="Fork Length (mm)")+theme_Publication()```